Godot Engine Game Development in 24 Hours, Sams Teach Yourself: The Official Guide to Godot 3.0 by Ariel Manzur & George Marques
Author:Ariel Manzur & George Marques
Language: eng
Format: epub, pdf
Publisher: Sams Publishing
Published: 2018-03-22T04:00:00+00:00
Loading Configuration Files
After you save the file to disk, only half the work is done. When the game starts again, you need to load the file from the disk and change the options to match the file. ConfigFile will also help you with that (see Listing 12.2).
LISTING 12.2 Loading Configurations
Click here to view code image
extends Node func _ready(): print(load_config()) # Should do something meaningful, but let's print for test purposes func load_config(): var path = "user://config.ini" # The path to load the file var config = ConfigFile.new() # Create a new ConfigFile object var default_options = { # Create a dictionary of default options "difficulty": "easy", "music_volume": 80 } var err = config.load(path) # Load the file from the disk if err != OK: # If there's an error return the default options return default_options var options = {} # Create a dictionary to store the loaded options # Get the values from the file or the predefined defaults if missing options.difficulty = config.get_value("options", "difficulty", default_options. difficulty) options.music_volume = config.get_value("audio", "music_volume", default _options.music_volume) return options # Return the loaded options
Download
Godot Engine Game Development in 24 Hours, Sams Teach Yourself: The Official Guide to Godot 3.0 by Ariel Manzur & George Marques.pdf
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(12590)
Hello! Python by Anthony Briggs(9926)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9802)
The Mikado Method by Ola Ellnestam Daniel Brolund(9787)
Dependency Injection in .NET by Mark Seemann(9348)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8309)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7771)
Grails in Action by Glen Smith Peter Ledbrook(7705)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7566)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7163)
Microservices with Go by Alexander Shuiskov(6932)
Practical Design Patterns for Java Developers by Miroslav Wengner(6848)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6793)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6423)
Angular Projects - Third Edition by Aristeidis Bampakos(6208)
The Art of Crafting User Stories by The Art of Crafting User Stories(5720)
NetSuite for Consultants - Second Edition by Peter Ries(5656)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5467)
Kotlin in Action by Dmitry Jemerov(5073)
